package Util;

public class Integral {

    public static double sum(double start, double stop,
            double stepSize, int M) {
        double sum = 0.0, current = start;
        while (current <= stop) {
            sum += Evaluatable.evaluate(current, M);
            current += stepSize;
        }
        return (sum);
    }

    public static double integrate(double start, double stop, int numSteps, int M) {
        double stepSize = (stop - start) / (double) numSteps;
        start = start + stepSize / 2.0;
        return (stepSize * sum(start, stop, stepSize, M));
    }
}